package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.pojo.SetmealMP;
import com.itheima.health.service.SetMealService;
import com.itheima.health.service.SetmealServiceMP;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/mobile/setmeal")
public class MobileSetmealController {

    @Autowired
    private SetMealService setmealService;
    @GetMapping("/findById")
    public Result findById(Integer id) {
        Setmeal setmeal = setmealService.findById(id);
        if (setmeal != null) {
            return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS, setmeal);
        } else {
            return new Result(false, MessageConst.QUERY_SETMEAL_FAIL);
        }
    }

    @GetMapping("/getSetmeal")
    public Result findAll() {
        List<Setmeal> all = setmealService.findAll();
        return new Result(true, MessageConst.QUERY_SETMEALLIST_SUCCESS, all);
    }
}
